<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="author" content="order by dede58.com" />
	<title>会员登录</title>
	<link rel="stylesheet" href="/public/default/css/login.css" />

	<script src="/public/default/js/jquery-1.10.1.js"></script>

</head>

<body class="login_page">
	<!-- login -->
	<div class="top center">
		<div class="logo center">
			<a href="./index.html" target="_blank"><img src="/public/default/image/mistore_logo.png" alt=""></a>
		</div>
	</div>
	<div class="form">
		<div class="login">

			<div class="login_center">
				<div class="login_top">
					<div class="left fl">会员登录</div>
					<div class="right fr">您还不是我们的会员？<a href="/register/registerStep1" target="_self">立即注册</a></div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>
				<div class="login_main center">
					<input type="hidden" name="_csrf" id="_csrf" value="<%=csrf%>">
					<div class="username">用户名：<input class="shurukuang" id="username" type="text" name="username"
							placeholder="请输入你的手机号" /></div>
					<div class="username">密　码：<input class="shurukuang" id="password" type="password" name="password"
							placeholder="请输入你的密码" /></div>
					<div class="username">
						<div class="left fl">验证码：<input class="yanzhengma" id="identify_code" type="text"
								name="identify_code" placeholder="请输入验证码" /></div>
						<div class="right fl">
							<img id="identify_code_img" src="/verify" title="看不清？点击刷新"
								onclick="javascript:this.src='/verify?mt='+Math.random()">
						</div>
						<div class="clear"></div>
					</div>
				</div>
				<div class="login_submit">

					<button class="submit" id="doLogin">立即登录</button>
				</div>
			</div>

		</div>
	</div>


	<script>
		$(function () {
			$("#doLogin").click(function (e) {

				var username = $('#username').val();
				var password = $('#password').val();
				var identify_code = $('#identify_code').val();
				var csrf = $('#_csrf').val();
				var reg = /^[\d]{11}$/;
				if (!reg.test(username)) {
					alert('手机号输入错误');
					return false;
				}
				if (identify_code.length < 4) {
					alert('验证码长度不合法');
					return false;
				}

				console.log(csrf)
				//ajax请求?_csrf=<%=csrf%>

				$.post('/pass/doLogin', {
					username: username,
					identify_code: identify_code,
					password: password,
					_csrf: csrf
				}, function (response) {
					console.log(response);
					if (response.success == true) {
						location.href = "/";
					} else {

						$("#identify_code_img").attr('src', '/verify?mt=' + Math.random());

						alert(response.msg);
					}
				})
			})

		})
	</script>

	<footer>
		<div class="copyright">简体 | 繁体 | English | 常见问题</div>
		<div class="copyright">小米公司版权所有-京ICP备10046444-<img src="/public/default/image/ghs.png"
				alt="">京公网安备11010802020134号-京ICP证110507号</div>

	</footer>
</body>

</html>